<script>
export default {
	onLaunch: function() {
		console.log('App Launch');
		this.$store.commit('setToken')
		this.$store.commit('userLogin')
		
		this.check();
		setTimeout(() => {
			this.update();
		}, 2000)
	},
	onShow: function() {
		console.log('App Show');
	},
	onHide: function() {
		console.log('App Hide');
	},
	data() {
		return {
			version: '666',
			name: '666'
		};
	},
	methods: {
		check() {
			plus.runtime.getProperty(plus.runtime.appid, info => {
				this.version = info.version
				this.name = info.name
			})
		},
		update() {
			this.$u.get('/update', {
				version: this.version,
				name: this.name
			}).then(res => {
				let data = res.data.result
				console.log(data)
				if (data.update) {
					uni.showModal({
						title: "更新提示",
						content: '有新版本更新，点击查看',
						success: (res) => {
							if (res.confirm) {
								this.$u.route('/pages/mine/update')
							}
						}
					})
				}
			})
		}
	}
};
</script>

<style lang="scss">	
	@import "/colorui/main.css";
	@import "/colorui/icon.css";
	@import "/uview-ui/index.scss";
	@import "/app.css";
</style>
